<?php
  function website_form_validation($form) {


	// district validation
	distvalidation($form['field_web_dist']['und']['#value']);


    // Check bad character validation for Title and Keywords field
    chkbadchar($form['title']['#value'], $form['title']['#title'], 'title');
    chkbadchar($form['taxonomy']['tags'][6]['#value'], $form['taxonomy']['tags'][6]['#title'], $form['taxonomy']['tags'][6]['#name']);
	chkbadchar($form['field_web_keyword']['und'][0]['value']['#value'], $form['field_web_keyword']['und'][0]['value']['#title'], 'field_web_keyword');
	chkbadchar($form['field_web_otherscategory']['und'][0]['value']['#value'], $form['field_web_otherscategory']['und'][0]['value']['#title'], 'field_web_otherscategory');
	//chkbadchar($form['field_web_url'][0]['value']['#value'], $form['field_web_url']['#title'], 'field_web_url');

	// minimum length charcter
  	minilength_validation($form['title']['#value'], 5, $form['title']['#title'], 'title');
  	minilength_validation($form['taxonomy']['tags'][6]['#value'],5, $form['taxonomy']['tags'][6]['#title'], $form['taxonomy']['tags'][6]['#name']);
	minilength_validation($form['field_web_keyword']['und'][0]['value']['#value'],5, $form['field_web_keyword']['und'][0]['value']['#title'], 'field_web_keyword');
	minilength_validation($form['field_web_otherscategory']['und'][0]['value'][0]['value']['#value'],5, $form['field_web_otherscategory']['und'][0]['value']['#title'], 'field_web_otherscategory');

	// Reference url validation
	url_validation($form['field_web_url']['und'][0]['value']['#value']);
  }
  // function website_form_validation()


  function website_presave_validation($node) {
    $reference_url = $node->field_web_url['und'][0]['value'];
    $node->field_web_url['und'][0]['value'] = url_validation($reference_url);
  }
